package FirstExam10tasks;

public class Task5 {

	public static void main(String[] args)
	{
		int[] arr = {1,2,9,3,4,5,6,9};
		int k = 3;
		
		findBiggestSum(arr, k);
		System.out.println(findBiggestSum(arr, k));
	}

	static int findBiggestSum (int[] arr, int k)
	{
		int max = 0;
		int a = 0;

		for(int i = 0; i < arr.length - k; i++)
		{
			
			for(int j = i; j < i + k ; j++)
			{
				a += arr[j];
				if(a > max)
				{
					max = a;
				}
			}
			a = 0;
		}
		
		return max;
	}
	
	
}
